package com.uoss.webapp.foundation.action;

import javax.annotation.Resource;

import org.uoss.applications.framework.exception.BIZException;
import org.uoss.webapp.framework.http.HttpUtil;
import org.uoss.webapp.framework.struts2.action.PaginationAction;

import com.uoss.applications.modules.foundation.biz.IAppBIZ;
import com.uoss.applications.modules.foundation.entities.TcApp;

public class AppAction extends PaginationAction<TcApp> {
	
	private static final long serialVersionUID = -8561536394283481041L;
	@Resource
	private IAppBIZ appBIZ;
	
	public String listApp(){
		return SUCCESS;
	}
	
	public String loadingApp(){
		try {
			this.toJSONObject(this.getAppBIZ().getAppResultSetByPaging(this.getQueryModel()));
		} 
		catch (BIZException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	public String addApp(){
		try {
			String appCode = HttpUtil.getHttpServletRequest().getParameter("appCode");
			String appName = HttpUtil.getHttpServletRequest().getParameter("appName");
			String appDesc = HttpUtil.getHttpServletRequest().getParameter("appDesc");
			this.entity = new TcApp();
			this.entity.setAppCode(appCode);
			this.entity.setAppName(appName);
			this.entity.setAppDesc(appDesc);
			this.getAppBIZ().addApp(this.entity);
			this.setStatus(SUCCESS);
		} 
		catch (BIZException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}

	public void setAppBIZ(IAppBIZ appBIZ) {
		this.appBIZ = appBIZ;
	}

	public IAppBIZ getAppBIZ() {
		return appBIZ;
	}
}
